class Person: def setdata(self,name,city): self.name=name self.city=city def showdata(self): print("Name is ",self.name) print("City is ",self.city) class Student(Person): def setdata(self,rollno,name,city): self.rollno=rollno super().setdata(name,city) def showdata(self): print("RollNo is",self.rollno) super().showdata() a=Person() a.setdata("Amit jain","Amravati") a.showdata() b=Student() b.setdata(4117,"Gopal Pandey" ,"Nagpur") b.showdata( )
Name is Amit Jain City is Amravati RollNo is 4117 Name is Gopal Pandey City is Nagpur
class Person: def __init__(self,name,city): self.name=name self.city=city def showdata(self): print("Name is ",self.name) print("City is ",self.city) class Student(Person): def __init__(self,rollno,name,city): self.rollno=rollno super().__init__(name,city) def showdata(self): print("RollNo is",self.rollno) super().showdata() a=Person("Amit jain","Amravati") a.showdata() b=Student(4117,"Gopal Pandey" ,"Nagpur") b.showdata( )
Name is Amit Jain City is Amravati RollNo is 4117 Name is Gopal Pandey City is Nagpur